package com.game.web.controller.core;

import java.util.List;
import org.springframework.stereotype.Controller;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.game.common.annotation.Log;
import com.game.common.enums.BusinessType;
import com.game.core.domain.PrUser;
import com.game.core.service.IPrUserService;
import com.game.framework.web.base.BaseController;
import com.game.common.page.TableDataInfo;
import com.game.common.base.AjaxResult;
import com.game.common.utils.poi.ExcelUtil;

/**
 * 登查人员 信息操作处理
 * 
 * @author game
 * @date 2020-12-12
 */
@Controller
@RequestMapping("/core/prUser")
public class PrUserController extends BaseController
{
    private String prefix = "core/prUser";
	
	@Autowired
	private IPrUserService prUserService;
	
	@RequiresPermissions("core:prUser:view")
	@GetMapping()
	public String prUser()
	{
	    return prefix + "/prUser";
	}
	
	/**
	 * 查询登查人员列表
	 */
	@RequiresPermissions("core:prUser:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PrUser prUser)
	{
		startPage();
        List<PrUser> list = prUserService.selectPrUserList(prUser);
		return getDataTable(list);
	}


	/**
	 * 查询字典详细
	 */
	@RequiresPermissions("system:dict:list")
	@GetMapping("/detail/{id}")
	public String detail(@PathVariable("id") Long id, ModelMap mmap)
	{
		mmap.put("uid", id);
		return "core/prUserUrl/prUserUrl";
	}
	
	
	/**
	 * 导出登查人员列表
	 */
	@RequiresPermissions("core:prUser:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PrUser prUser)
    {
    	List<PrUser> list = prUserService.selectPrUserList(prUser);
        ExcelUtil<PrUser> util = new ExcelUtil<PrUser>(PrUser.class);
        return util.exportExcel(list, "prUser");
    }
	
	/**
	 * 新增登查人员
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存登查人员
	 */
	@RequiresPermissions("core:prUser:add")
	@Log(title = "登查人员", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PrUser prUser)
	{		
		return toAjax(prUserService.save(prUser));
	}

	/**
	 * 修改登查人员
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		PrUser prUser = prUserService.selectPrUserById(id);
		mmap.put("prUser", prUser);
		return prefix + "/edit";
	}

	/**
	 * 修改保存登查人员
	 */
	@RequiresPermissions("core:prUser:edit")
	@Log(title = "登查人员", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PrUser prUser)
	{		
		return toAjax(prUserService.updateById(prUser));
	}
	
	/**
	 * 删除登查人员
	 */
	@RequiresPermissions("core:prUser:remove")
	@Log(title = "登查人员", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(prUserService.deletePrUserByIds(ids));
	}
	
}
